/*
 * Copyright (C) 2015-2016  Nicola Spanti (RyDroid) <dev@nicola-spanti.info>
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */


#include "PlanetWars2dRT-core/specific/model/ship_default.h"
#include "PlanetWars2dRT-core/specific/model/ship_position.h"
#include "PlanetWars2dRT-core/specific/model/players_info.h"


EXTERN_C_BEGIN


void
ship_set_default_size(ship_t* a_ship)
{
  a_ship->size.x = SHIP_SIZE_X_DEFAULT;
  a_ship->size.y = SHIP_SIZE_Y_DEFAULT;
}

void
ship_set_default_life(ship_t* a_ship)
{
  a_ship->life_current = SHIP_LIFE_MAX_DEFAULT;
  a_ship->life_max     = SHIP_LIFE_MAX_DEFAULT;
}

ship_t
ship_create_default_for_a_player(const position_2d_uint* position_current,
				 const position_2d_uint* position_to_go,
				 unsigned char player_index)
{
  struct ship_t a_ship;
  ship_set_top_left_position_current(&a_ship, position_current);
  a_ship.position_to_go = *position_to_go;
  a_ship.moving_vector = SHIP_MOVING_VECTOR_DEFAULT;
  ship_set_default_size(&a_ship);
  a_ship.power = SHIP_POWER_DEFAULT;
  ship_set_default_life(&a_ship);
  a_ship.player_index = player_index;
  observers_init_first_time_only(&a_ship.observers);
  return a_ship;
}

ship_t
ship_create_default(const position_2d_uint* position_current,
		    const position_2d_uint* position_to_go)
{
  return ship_create_default_for_a_player(position_current,
					  position_to_go,
					  NULL_PLAYER_INDEX);
}


EXTERN_C_END
